// pages/wmm/pdd_income.js
const app = getApp();

Page({

    /**
     * 页面的初始数据
     */
    data: {
        money: 0,
        list: [{}, {}, {}],
        page: 1
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.setData({
            money: app.globalData.balance_pdd
        })
        this.getList()
    },
    getList: function () {
        wx.showLoading({
            title: '加载中',
            mask: false
        })
        var that = this;
        wx.request({
            url: app.globalData.api + '/app.php?c=UserBalancePdd&a=getRecord',
            data: {
                token: app.globalData.token,
                p: this.data.page,
                per: 30
            },
            header: {
                "Content-Type": "application/x-www-form-urlencoded",
            },
            method: 'POST',
            dataType: 'json',
            success: function (res) {

                console.log('ppp');
                wx.hideLoading();
                wx.stopPullDownRefresh({
                    success: (res) => {},
                })
                if (res.data.code == 0) {
                    var priceQuan;
                    if (that.data.page == 1) {
                        that.setData({
                            list: []
                        })
                    }
                    that.setData({
                        list: that.data.list.concat(res.data.data.list)
                    })
                } else {
                    wx.showToast({
                        title: '' + res.data.message,
                        icon: 'none'
                    })
                    that.setData({
                        list: []
                    })
                }

            },
            fail: function () {
                wx.hideLoading();
            }
        });
    },
    onPullDownRefresh: function () {
        this.setData({
            page: 1
        })
        this.getList()
    },
    onReachBottom() {
        this.setData({
            page: this.data.page + 1
        })
        this.getList()
    },
    draw:function(){
        if(app.globalData.alipay_account){
            wx.navigateTo({
              url: 'pdd_draw',
            })
          }else{
            wx.navigateTo({
              url: '/pages/mine/setting-bindaliay',
            })
          }
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})